<template>
    <div class="fillcontain">
        <div class="table_container">
            <el-table
                :data="tableData"
                highlight-current-row
                style="width: 100%">
                <el-table-column
                  type="index"
                  width="100">
                </el-table-column>
                <el-table-column
                    property="id"
                    label="id"
                    width="220">
                </el-table-column>
                <el-table-column
                  property="city"
                  label="城市"
                  width="220">
                </el-table-column>
                <el-table-column
                  property="detailedAddress"
                  label="详细地址"
                  width="220">
                </el-table-column>
                <el-table-column
                  property="province"
                  label="省份">
                </el-table-column>
                <el-table-column label="操作" width="200">
                    <template slot-scope="scope">
                        <el-button
                            size="mini"
                            type="danger"
                            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                      <el-button
                          size="mini"
                          type="danger"
                          @click="handleaddress(scope.$index, scope.row)">设为默认地址</el-button>
                    </template>

                </el-table-column>
            </el-table>
        </div>
    </div>
</template>

<script>

    export default {
        data(){
            return {
                tableData: [],
                currentRow: null,
                offset: 0,
                limit: 2,
                count: 0,
                currentPage: 1,
            }
        },
    	components: {
    	},
        created(){
            this.queryAddresses()
        },
        methods: {
          queryAddresses()
          {
            axios.get('http://myphoenixshop.cpolar.io/getAddresses',{
              headers:{
                "tokenValue":this.$store.getters.getUser
              }
            }).then(res=>{
              console.log(res);
              this.tableData=res.data.data;
            })
          },
            handleDelete(index, row) {
              axios.post('http://myphoenixshop.cpolar.io/deleteAddress', {
                addressesId:row.id
              },{
                headers:{
                  "tokenValue":this.$store.getters.getUser
                }
              }).then(res=>{
                console.log(res);
              })
            },
          handleaddress(index, row){

            axios.post('http://myphoenixshop.cpolar.io/setDefaultAddress', {
              addressesId:row.id
            },{
              headers:{
                "tokenValue":this.$store.getters.getUser
              }
            }).then(res=>{
              console.log(res);
            })
          }
        }

    }
</script>

<style lang="less">
	@import '../style/mixin';
    .table_container{
        padding: 20px;
    }
</style>
